<template>
    <div class="zh-organization organizational-s">
            <nav-header></nav-header>
            <div class="zh-table">
                <div class="zh-table-open clear">
                    <div class="zh-open-right fr">
                        <el-button type="primary" @click="getOrgData">刷新</el-button>
                    </div>
                </div>
                <div class="zh-tree-contents "
                    v-loading="loading.status"
                    :element-loading-text="loading.txt"
                >
                <div class="frame-manage">
                        <ul class="frame-list">
                            <li><div class="ellips">序号</div></li>
                            <li><div class="ellips">名称</div></li>
                            <li><div class="ellips">超级管理员</div></li>
                            <li><div class="ellips">状态</div></li>
                            <li><div class="ellips">操作</div></li>
                        </ul>
                    <el-tree
                    :data="orgData"
                    :props="defaultProps"
                    node-key="id"
                    default-expand-all>
                    <div class="custom-tree-node" slot-scope="{ node, data }">
                        <ul class="frame-list">
                            <li><div class="ellips">{{ orgData[0].inx++ }}</div></li>
                            <li>
                                <div class="ellips">
                                    <span v-show="node.level >= 2" class="gap"></span>
                                    <span v-show="node.level >= 3" class="gap"></span>
                                    <span v-show="node.level >= 4" class="gap"></span>
                                    <span v-show="node.level >= 5" class="gap"></span>
                                    <span v-show="node.level >= 6" class="gap"></span>
                                    <span v-show="node.level >= 7" class="gap"></span>
                                    <span v-show="node.level >= 8" class="gap"></span>
                                    <span v-show="node.level >= 9" class="gap"></span>
                                    <img v-if="data.server_type === 2" src="/static/image/user/edu.png">
                                    <img v-if="data.server_type === 1" src="/static/image/user/sch.png">
                                    <img v-if="data.level === 2" src="/static/image/user/tree2.png">
                                    <img v-if="data.level === 3" src="/static/image/user/tree3.png">
                                    <img v-if="data.level === 4" src="/static/image/user/tree4.png">
                                    <span v-html="data.name"></span>
                                </div>
                            </li>
                            <li>
                                <div class="ellips" v-if="node.level === 1"><span>-</span></div>
                                <div class="ellips" v-else-if="data.admin_id"><span>{{ data.admin_name }}</span></div>
                                <div class="ellips" v-else><span>-</span></div>
                            </li>
                            <li>
                                <div class="ellips" v-if="data.status == 1"><span class="link">{{ data.server_type == 2 && node.level === 1 ? '-' : '已启用' }}</span></div>
                                <div class="ellips" v-else-if="data.status == 2"><span class="link">{{ data.server_type == 2 && node.level === 1 ? '-' : '已禁用' }}</span></div>
                                <div class="ellips" v-else-if="data.status == 0"><span class="link">{{ data.server_type == 2 && node.level === 1 ? '-' : '已删除' }}</span></div>
                                <div class="ellips" v-else-if="data.status == 3"><span class="link">{{ data.server_type == 2 && node.level === 1 ? '-' : '已毕业' }}</span></div>
                            </li>
                            <li style="text-align:left;">
                                <div style="width:100%;height:100%;padding-left:60px;box-sizing:border-box;">
                                    <!-- 编辑教育局 -->
                                    <el-button type="text" size="mini" v-if="data.level == 1 && data.server_type == 2" @click.stop="editEducationTrigger(data, '编辑')">编辑</el-button>
                                    <!-- 编辑学校 -->
                                    <el-button type="text" size="mini" v-else-if="data.level == 1 && data.server_type == 1" @click.stop="editSchoolTrigger(data)">编辑</el-button>
                                    <!-- 编辑学段 -->
                                    <el-button type="text" size="mini" v-else-if="data.level === 2 && data.cate_type === 1" @click.stop="editFieldTrigger(data)">编辑</el-button>
                                    <!-- 编辑院系 -->
                                    <el-button type="text" size="mini" v-else-if="data.level === 2 && data.cate_type === 2" @click.stop="editFacTrigger(data)">编辑</el-button>
                                    <!-- 编辑类别 -->
                                    <el-button type="text" size="mini" v-else-if="data.level === 2 && data.cate_type === 3" @click.stop="editKindTrigger(data)">编辑</el-button>
                                    <!-- 编辑专业 -->
                                    <el-button type="text" size="mini" v-else-if="data.level === 3 && (data.cate_type === 2 || data.cate_type === 3)" @click.stop="editMajorTrigger(data)">编辑</el-button>
                                    <!-- 编辑年级 -->
                                    <el-button type="text" size="mini" v-else-if="data.level === 3 && data.cate_type === 1" @click.stop="editClassTrigger(data)">编辑</el-button>
                                    <!-- 编辑班级 -->
                                    <el-button type="text" size="mini" v-else-if="data.level == 4" @click.stop="editTissueTrigger(data)">编辑</el-button>
                                    <!-- 添加教育局------------------------------- server_type 2 为教育局 可添加教育局与学校 node.level 最高九级--------------------------- -->
                                    <el-button type="text" size="mini" v-if="data.server_type === 2 && node.level !== 9" @click.stop="addEducationTrigger(data)">添加教育局</el-button>
                                    <!-- 添加教育局---------------------------------------------------------- -->
                                    <!-- 添加学校----------------------------- -->
                                    <el-button type="text" size="mini" v-if="data.server_type === 2" @click.stop="addSchoolTrigger(data.id)">添加学校</el-button>
                                    <!-- 添加学校----------------------------- -->
                                    <!-- 添加学段---------------------------------- -->
                                    <el-button type="text" size="mini" v-if="data.server_type === 1 && data.cate_type == 1" @click.stop="addTownFlagTrigger(data)">添加学段</el-button>
                                    <el-button type="text" size="mini" v-else-if="data.server_type === 1 && data.cate_type == 2" @click.stop="addFacultyFlagTrigger(data)">添加院系</el-button>
                                    <el-button type="text" size="mini" v-else-if="data.server_type === 1 && data.cate_type == 3" @click.stop="addKindFlagTrigger(data)">添加类别</el-button>
                                    <!-- 添加学段---------------------------------- -->
                                    <!-- 添加年级----------------------------------- -->
                                    <el-button type="text" size="mini" v-if="data.level === 2 && data.cate_type === 1" @click.stop="addGradeFlagTrigger(data)">添加年级</el-button>
                                    <el-button type="text" size="mini" v-else-if="data.level === 2 && (data.cate_type === 2 || data.cate_type === 3)" @click.stop="addMajorFlagTrigger(data)">添加专业</el-button>
                                    <!-- 添加年级----------------------------------- -->
                                    <!-- 添加班级---------------------------------------------------- -->
                                    <el-button type="text" size="mini" v-if="data.level === 3" @click.stop="addClassFlagTrigger(data)">添加班级</el-button>
                                    <!-- 添加班级---------------------------------------------------- -->
                                    <!-- 禁用/启用 教育局/学校 ------------------------------------------- -->
                                    <el-button type="text" v-if="node.level !== 1 && data.level == 1 && data.status == 1" size="mini" key="data" class="delete-button" @click.stop="stopEducationTrigger(data)">禁用</el-button>
                                    <el-button type="text" v-if="node.level !== 1 && data.level == 1 && data.status == 2" key="data0" size="mini" @click.stop="startEducationTrigger(data)">启用</el-button>
                                    <!-- 禁用/启用 组织架构+++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
                                    <el-button type="text" v-else-if="node.level !== 1 && data.level >= 2 && data.status == 1" size="mini" class="delete-button" @click.stop="stopTissueTrigger(data)">禁用</el-button>
                                    <el-button type="text" v-else-if="node.level !== 1 && data.level >= 2 && data.status == 2" size="mini" @click.stop="startTissueTrigger(data)">启用</el-button>
                                    <!-- 删除教育局/学校------------------------------------------------- -->
                                    <el-button type="text" v-if="node.level !== 1 && data.level == 1 " size="mini" class="delete-button" @click.stop="delEducationTrigger(data.id, data.app_code, data.name)">删除</el-button>
                                    <!-- 删除教育局/学校------------------------------------------------- -->
                                    <!-- 删除组织。。学段/院系/类别/年级/专业/班级 -------------------- -->
                                    <el-button type="text" v-else-if="node.level !== 1 && data.level >= 2 " size="mini" class="delete-button" @click.stop="delTissueTrigger(data)">删除</el-button>
                                    <!-- 删除组织。。学段/院系/类别/年级/专业/班级 -------------------- -->
                                </div>
                            </li>
                        </ul>
                    </div>
                    </el-tree>
                    </div>
                </div>
            </div>
        <!--弹窗 添加教育局 --------------------------------------------------------------------- -->
        <el-dialog
        title="添加教育局"
        :visible.sync="addEducationFlag"
        :close-on-click-modal="false" 
        :close-on-press-escape="false"
        @close="handleClose"
        width="40%"
        >
        <el-form ref="educationForm" :model="educationForm" :rules="rules" label-width="120px" @submit.native.prevent>
            <el-form-item label="教育局名称" prop="eduname">
            <el-input type="text" placeholder="请输入教育局名称" v-model.trim="educationForm.eduname" maxlength="20"> </el-input>
            </el-form-item>
            <el-form-item label="管理员账号" prop="number">
            <el-input type="text" placeholder="创建管理员账号" v-model.trim="educationForm.number" maxlength="20"> </el-input>
            </el-form-item>
            <el-form-item label="密码" prop="password">
            <el-input type="password" placeholder="不填时默认为666666" v-model.trim="educationForm.password"> </el-input>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="addEducationTips()">取 消</el-button>
            <el-button type="primary" @click="addEducationTips(1)">确 定</el-button>
        </span>
        </el-dialog>
        <!--弹窗  添加教育局 ----------------------------------------------------------------------------- -->

        <!--弹窗 编辑教育局 --------------------------------------------------------------------- -->
        <el-dialog
        title="编辑教育局"
        :visible.sync="editEducationFlag"
        :close-on-click-modal="false" 
        :close-on-press-escape="false"
        @close="handleClose"
        width="40%"
        >
        <el-form ref="educationForm" :model="educationForm" :rules="rules" label-width="120px" @submit.native.prevent>
            <el-form-item label="教育局名称" prop="eduname">
            <el-input type="text" placeholder="请输入教育局名称" v-model.trim="educationForm.eduname" maxlength="20"> </el-input>
            </el-form-item>
            <el-form-item label="管理员账号" prop="number">
            <el-input type="text" placeholder="创建管理员账号" v-model.trim="educationForm.number" maxlength="20"> </el-input>
            </el-form-item>
            <el-form-item label="密码" prop="password">
            <el-input type="password" placeholder="不填时默认不修改" v-model.trim="educationForm.password"> </el-input>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="editEducationTips()">取 消</el-button>
            <el-button type="primary" @click="editEducationTips(1)">确 定</el-button>
        </span>
        </el-dialog>
        <!--弹窗  编辑教育局 ----------------------------------------------------------------------------- -->

        <!--弹窗 删除教育局/学校--------------------------------------------------- -->
        <el-dialog
        title="删除"
        :visible.sync="delEducationFlag"
        :close-on-click-modal="false" 
        :close-on-press-escape="false"
        @close="handleClose"
        width="40%"
        >
            <span style="padding-left: 10px;display: block;margin-bottom: 30px;">该操作将造成严重不可逆影响，是否确认删除{{ this.delstop.name }}？</span>
            <el-form ref="delEducationForm" :model="delEducationForm" :rules="rules" label-width="120px" @submit.native.prevent>
                <el-form-item label="超级管理员密码" prop="password">
                    <el-input type="password" placeholder="" v-model.trim="delEducationForm.password"> </el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="delEducationTips()">取 消</el-button>
                <el-button type="primary" @click="delEducationTips(1)">确 定</el-button>
            </span>
        </el-dialog>
        <!-- 弹窗 删除教育局/学校--------------------------------------------------- -->

        <!--弹窗 删除组织--------------------------------------------------- -->
        <el-dialog
        title="删除"
        :visible.sync="delTissueFlag"
        :close-on-click-modal="false" 
        :close-on-press-escape="false"
        @close="handleClose"
        width="40%"
        >
            <span style="padding-left: 10px;display: block;margin-bottom: 30px;">该操作将造成严重不可逆影响，是否确认删除{{ this.delstop.name }}？</span>
            <el-form ref="delEducationForm" :model="delEducationForm" :rules="rules" label-width="120px" @submit.native.prevent>
                <el-form-item label="超级管理员密码" prop="password">
                <el-input type="password" placeholder="" v-model.trim="delEducationForm.password"> </el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="delTissueTips()">取 消</el-button>
                <el-button type="primary" @click="delTissueTips(1)">确 定</el-button>
            </span>
        </el-dialog>
        <!-- 弹窗 删除组织--------------------------------------------------- -->

        <!-- 弹窗 禁用教育局/学校--------------------------------------------------- -->
        <el-dialog
        title="禁用"
        :visible.sync="stopEducationFlag"
        :close-on-click-modal="false" 
        :close-on-press-escape="false"
        @close="handleClose"
        width="40%"
        >
            <span style="padding-left: 10px;display: block;margin-bottom: 30px;">该操作将造成严重不可逆影响，是否确认禁用{{ this.delstop.name }}？</span>
            <el-form ref="delEducationForm" :model="delEducationForm" :rules="rules" label-width="120px" @submit.native.prevent>
                <el-form-item label="超级管理员密码" prop="password">
                    <el-input type="password" placeholder="" v-model.trim="delEducationForm.password"> </el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="stopEducationTips()">取 消</el-button>
                <el-button type="primary" @click="stopEducationTips(1)">确 定</el-button>
            </span>
        </el-dialog>
        <!-- 弹窗 禁用教育局/学校--------------------------------------------------- -->

        <!-- 弹窗 禁用组织--------------------------------------------------- -->
        <el-dialog
        title="禁用"
        :visible.sync="stopTissueFlag"
        :close-on-click-modal="false" 
        :close-on-press-escape="false"
        @close="handleClose"
        width="40%"
        >
            <span style="padding-left: 10px;display: block;margin-bottom: 30px;">该操作将造成严重不可逆影响，是否确认禁用{{ this.delstop.name }}？</span>
            <el-form ref="delEducationForm" :model="delEducationForm" :rules="rules" label-width="120px" @submit.native.prevent>
                <el-form-item label="超级管理员密码" prop="password">
                <el-input type="password" placeholder="" v-model.trim="delEducationForm.password"> </el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="stopTissueTips()">取 消</el-button>
                <el-button type="primary" @click="stopTissueTips(1)">确 定</el-button>
            </span>
        </el-dialog>
        <!-- 弹窗 禁用组织--------------------------------------------------- -->

        <!-- 弹窗 启用教育局/学校------------------------------------------------------ -->
        <el-dialog
        title="启用"
        :visible.sync="startEducationFlag"
        :close-on-click-modal="false" 
        :close-on-press-escape="false"
        @close="handleClose"
        width="40%"
        >
            <span style="padding-left: 10px;display: block;margin-bottom: 30px;">是否确认启用{{ this.delstop.name }}？</span>
            <el-form ref="delEducationForm" :model="delEducationForm" :rules="rules" label-width="120px" @submit.native.prevent>
                <el-form-item label="超级管理员密码" prop="password">
                <el-input type="password" placeholder="" v-model.trim="delEducationForm.password"> </el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="startEducationTips()">取 消</el-button>
                <el-button type="primary" @click="startEducationTips(1)">确 定</el-button>
            </span>
        </el-dialog>
        <!-- 弹窗 启用教育局/学校------------------------------------------------------ -->

        <!-- 弹窗 启用组织------------------------------------------------------ -->
        <el-dialog
        title="启用"
        :visible.sync="startTissueFlag"
        :close-on-click-modal="false" 
        :close-on-press-escape="false"
        @close="handleClose"
        width="40%"
        >
            <span style="padding-left: 10px;display: block;margin-bottom: 30px;">是否确认启用{{ this.delstop.name }}？</span>
            <el-form ref="delEducationForm" :model="delEducationForm" label-width="120px" @submit.native.prevent>
                <el-form-item label="超级管理员密码" prop="password" :rules="[{ validator: checkValue }]">
                <el-input type="password" placeholder="" v-model.trim="delEducationForm.password"> </el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="startTissueTips()">取 消</el-button>
                <el-button type="primary" @click="startTissueTips(1)">确 定</el-button>
            </span>
        </el-dialog>
        <!-- 弹窗 启用组织------------------------------------------------------ -->

        <!-- 添加学校begin -->
        <el-dialog
        title="添加学校"
        :visible.sync="addSchoolFlag"
        :close-on-click-modal="false" 
        :close-on-press-escape="false"
        @close="handleClose"
        width="40%"
        >
        <el-form ref="schoolForm" :model="schoolForm" :rules="rules" label-width="120px" @submit.native.prevent>
            <el-form-item label="学校名称" prop="schname">
            <el-input type="text" placeholder="请输入学校名称" v-model.trim="schoolForm.schname" maxlength="10"> </el-input>
            </el-form-item>
            <el-form-item label="类型" prop="type">
                <el-radio-group v-model="schoolForm.radio">
                    <el-radio :label="1">普通教育</el-radio>
                    <el-radio :label="2">高等教育</el-radio>
                    <el-radio :label="3">成人教育</el-radio>
                </el-radio-group>
            </el-form-item>
            <el-form-item label="管理员账号" prop="number">
            <el-input type="text" placeholder="创建管理员账号" v-model.trim="schoolForm.number" maxlength="20"> </el-input>
            </el-form-item>
            <el-form-item label="密码" prop="password">
            <el-input type="password" placeholder="不填时默认为666666" v-model.trim="schoolForm.password"> </el-input>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="addSchoolTips()">取 消</el-button>
            <el-button type="primary" @click="addSchoolTips(1)">确 定</el-button>
        </span>
        </el-dialog>
        <!-- 添加学校end -->

        <!-- 编辑学校begin -->
        <el-dialog
        title="编辑学校"
        :visible.sync="editSchoolFlag"
        :close-on-click-modal="false" 
        :close-on-press-escape="false"
        @close="handleClose"
        width="40%"
        >
        <el-form ref="schoolForm" :model="schoolForm" :rules="rules" label-width="120px" @submit.native.prevent>
            <el-form-item label="学校名称" prop="schname">
            <el-input type="text" placeholder="请输入学校名称" v-model.trim="schoolForm.schname" maxlength="20"> </el-input>
            </el-form-item>
            <el-form-item label="类型" prop="type">
                <el-radio-group v-model="schoolForm.radio">
                    <el-radio :disabled="(schoolChild.length == 0) ? false : true" :label="1">普通教育</el-radio>
                    <el-radio :disabled="(schoolChild.length == 0) ? false : true" :label="2">高等教育</el-radio>
                    <el-radio :disabled="(schoolChild.length == 0) ? false : true" :label="3">成人教育</el-radio>
                </el-radio-group>
            </el-form-item>
            <el-form-item label="管理员账号" prop="number">
            <el-input type="text" placeholder="创建管理员账号" v-model.trim="schoolForm.number" maxlength="20"> </el-input>
            </el-form-item>
            <el-form-item label="密码" prop="password">
            <el-input type="password" placeholder="不填时默认为666666" v-model.trim="schoolForm.password"> </el-input>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="editSchoolTips()">取 消</el-button>
            <el-button type="primary" @click="editSchoolTips(1)">确 定</el-button>
        </span>
        </el-dialog>
        <!-- 编辑学校end -->

        <!-- 添加学段 ------------------------------------------------ 弹窗 -->
        <el-dialog
        title="添加学段"
        :visible.sync="addTownFlag"
        :close-on-click-modal="false" 
        :close-on-press-escape="false"
        @close="handleClose"
        width="40%"
        >
        <el-form ref="addTownForm" :model="addTownForm" label-width="120px" @submit.native.prevent>
            <el-form-item label="类型" prop="type">
                <el-radio-group v-model="addTownForm.radio">
                    <el-radio :label="1">普通教育</el-radio>
                </el-radio-group>
            </el-form-item>
            <el-form-item label="选择学段">
                <el-select v-model="addTownForm.region" placeholder="请选择添加的学段" >
                    <el-option label="小学" value="小学">小学</el-option>
                    <el-option label="初中" value="初中">初中</el-option>
                    <el-option label="高中" value="高中">高中</el-option>
                </el-select>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="addTownTips()">取 消</el-button>
            <el-button type="primary" @click="addTownTips(1)">确 定</el-button>
        </span>
        </el-dialog>
        <!-- 添加学段 ------------------------------------------------ 弹窗 -->

        <!-- 编辑学段 ------------------------------------------------ 弹窗 -->
        <el-dialog
        title="编辑学段"
        :visible.sync="editFieldFlag"
        :close-on-click-modal="false" 
        :close-on-press-escape="false"
        @close="handleClose"
        width="40%"
        >
        <el-form ref="addTownForm" :model="addTownForm" label-width="120px" @submit.native.prevent>
            <el-form-item label="类型" prop="type">
                <el-radio-group v-model="addTownForm.radio">
                    <el-radio :label="1">普通教育</el-radio>
                </el-radio-group>
            </el-form-item>
            <el-form-item label="选择学段">
                <el-select v-model="addTownForm.region" placeholder="请选择添加的学段" >
                    <el-option label="小学" value="小学">小学</el-option>
                    <el-option label="初中" value="初中">初中</el-option>
                    <el-option label="高中" value="高中">高中</el-option>
                </el-select>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="editTissueTips()">取 消</el-button>
            <el-button type="primary" @click="editTissueTips(1)">确 定</el-button>
        </span>
        </el-dialog>
        <!-- 编辑学段 ------------------------------------------------ 弹窗 -->

        <!-- 添加院系 ------------------------------------------------ 弹窗 -->
        <el-dialog
        title="添加院系"
        :visible.sync="addFacultyFlag"
        :close-on-click-modal="false" 
        :close-on-press-escape="false"
        @close="handleClose"
        width="40%"
        >
        <el-form ref="addTownForm" :model="addTownForm" label-width="120px" @submit.native.prevent>
            <el-form-item label="类型" prop="type">
                <el-radio-group v-model="addTownForm.radio">
                    <el-radio :label="1">高等教育</el-radio>
                </el-radio-group>
            </el-form-item>
            <el-form-item label="院系" prop="region" :rules="[{message: '请输入院系名称',validator: checkValue}]">
                <el-input type="text" placeholder="请输入院系名称" v-model.trim="addTownForm.region" maxlength="20"> </el-input>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="addFacultyTips()">取 消</el-button>
            <el-button type="primary" @click="addFacultyTips(1)">确 定</el-button>
        </span>
        </el-dialog>
        <!-- 添加院系 ------------------------------------------------ 弹窗 -->

        <!-- 编辑院系 ------------------------------------------------ 弹窗 -->
        <el-dialog
        title="编辑院系"
        :visible.sync="editFacFlag"
        :close-on-click-modal="false" 
        :close-on-press-escape="false"
        @close="handleClose"
        width="40%"
        >
        <el-form ref="addTownForm" :model="addTownForm" label-width="120px" @submit.native.prevent>
            <el-form-item label="类型" prop="type">
                <el-radio-group v-model="addTownForm.radio">
                    <el-radio :label="1">高等教育</el-radio>
                </el-radio-group>
            </el-form-item>
            <el-form-item label="院系" prop="region" :rules="[{message: '请输入院系名称',validator: checkValue}]">
            <el-input type="text" placeholder="请输入院系名称" v-model.trim="addTownForm.region" maxlength="20"> </el-input>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="editTissueTips()">取 消</el-button>
            <el-button type="primary" @click="editTissueTips(1)">确 定</el-button>
        </span>
        </el-dialog>
        <!-- 编辑院系 ------------------------------------------------ 弹窗 -->

        <!-- 添加类别 ------------------------------------------------ 弹窗 -->
        <el-dialog
        title="添加类别"
        :visible.sync="addKindFlag"
        :close-on-click-modal="false" 
        :close-on-press-escape="false"
        @close="handleClose"
        width="40%"
        >
        <el-form ref="addTownForm" :model="addTownForm" label-width="120px" @submit.native.prevent>
            <el-form-item label="类型" prop="type">
                <el-radio-group v-model="addTownForm.radio">
                    <el-radio :label="1">成人教育</el-radio>
                </el-radio-group>
            </el-form-item>
            <el-form-item label="类别" prop="region" :rules="[{message: '请输入类别名称',validator: checkValue}]">
            <el-input type="text" placeholder="请输入类别，如建筑工程类" v-model.trim="addTownForm.region" maxlength="20"> </el-input>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="addKindTips()">取 消</el-button>
            <el-button type="primary" @click="addKindTips(1)">确 定</el-button>
        </span>
        </el-dialog>
        <!-- 添加类别 ------------------------------------------------ 弹窗 -->

        <!-- 编辑类别 ------------------------------------------------ 弹窗 -->
        <el-dialog
        title="编辑类别"
        :visible.sync="editKindFlag"
        :close-on-click-modal="false" 
        :close-on-press-escape="false"
        @close="handleClose"
        width="40%"
        >
        <el-form ref="addTownForm" :model="addTownForm" label-width="120px" @submit.native.prevent>
            <el-form-item label="类型" prop="type">
                <el-radio-group v-model="addTownForm.radio">
                    <el-radio :label="1">成人教育</el-radio>
                </el-radio-group>
            </el-form-item>
            <el-form-item label="类别" prop="region" :rules="[{message: '请输入类别名称',validator: checkValue}]">
            <el-input type="text" placeholder="请输入类别，如建筑工程类" v-model.trim="addTownForm.region" maxlength="20"> </el-input>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="editTissueTips()">取 消</el-button>
            <el-button type="primary" @click="editTissueTips(1)">确 定</el-button>
        </span>
        </el-dialog>
        <!-- 编辑类别 ------------------------------------------------ 弹窗 -->

        <!-- 添加年级 ------------------------------------------------ 弹窗 -->
        <el-dialog
        title="添加年级"
        :visible.sync="addGradeFlag"
        :close-on-click-modal="false" 
        :close-on-press-escape="false"
        @close="handleClose"
        width="40%"
        >
        <el-form ref="addTownForm" :model="addTownForm" label-width="120px" @submit.native.prevent>
            <el-form-item label="输入年级：" prop="region" :rules="[{message: '请输入年级名称',validator: checkValue,}]">
            <el-input type="text" placeholder="" v-model.trim="addTownForm.region" maxlength="20"> </el-input>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="addGradeTips()">取 消</el-button>
            <el-button type="primary" @click="addGradeTips(1)">确 定</el-button>
        </span>
        </el-dialog>
        <!-- 添加年级 ------------------------------------------------ 弹窗 -->

        <!-- 编辑年级 ------------------------------------------------ 弹窗 -->
        <el-dialog
        title="编辑年级"
        :visible.sync="editClassFlag"
        :close-on-click-modal="false" 
        :close-on-press-escape="false"
        @close="handleClose"
        width="40%"
        >
        <el-form ref="addTownForm" :model="addTownForm" label-width="120px" @submit.native.prevent>
            <el-form-item label="输入年级：" prop="region" :rules="[{message: '请输入年级名称',validator: checkValue}]">
            <el-input type="text" placeholder="" v-model.trim="addTownForm.region" maxlength="20"> </el-input>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="editTissueTips()">取 消</el-button>
            <el-button type="primary" @click="editTissueTips(1)">确 定</el-button>
        </span>
        </el-dialog>
        <!-- 编辑年级 ------------------------------------------------ 弹窗 -->

        <!-- 添加专业 ------------------------------------------------ 弹窗 -->
        <el-dialog
        title="添加专业"
        :visible.sync="addMajorFlag"
        :close-on-click-modal="false" 
        :close-on-press-escape="false"
        @close="handleClose"
        width="40%"
        >
        <el-form ref="addTownForm" :model="addTownForm" label-width="120px" @submit.native.prevent>
            <el-form-item label="专业名称：" prop="region" :rules="[{message: '请输入专业名称',validator: checkValue}]">
            <el-input type="text" placeholder="" v-model.trim="addTownForm.region" maxlength="20"> </el-input>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="addMajorTips()">取 消</el-button>
            <el-button type="primary" @click="addMajorTips(1)">确 定</el-button>
        </span>
        </el-dialog>
        <!-- 添加专业 ------------------------------------------------ 弹窗 -->

        <!-- 编辑专业 ------------------------------------------------ 弹窗 -->
        <el-dialog
        title="编辑专业"
        :visible.sync="editMajorFlag"
        :close-on-click-modal="false" 
        :close-on-press-escape="false"
        @close="handleClose"
        width="40%"
        >
        <el-form ref="addTownForm" :model="addTownForm" label-width="120px" @submit.native.prevent>
            <el-form-item label="专业名称：" prop="region" :rules="[{message: '请输入专业名称',validator: checkValue}]">
            <el-input type="text" placeholder="" v-model.trim="addTownForm.region" maxlength="20"> </el-input>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="editTissueTips()">取 消</el-button>
            <el-button type="primary" @click="editTissueTips(1)">确 定</el-button>
        </span>
        </el-dialog>
        <!-- 编辑专业 ------------------------------------------------ 弹窗 -->

        <!-- 添加班级 ------------------------------------------------ 弹窗 -->
        <el-dialog
        title="添加班级"
        :visible.sync="addClassFlag"
        :close-on-click-modal="false" 
        :close-on-press-escape="false"
        @close="handleClose"
        width="40%"
        >
        <el-form ref="addTownForm" :model="addTownForm" label-width="120px" @submit.native.prevent>
            <el-form-item label="班级名称：" prop="region" :rules="[{message: '请输入班级名称',validator: checkValue}]">
            <el-input type="text" placeholder="" v-model.trim="addTownForm.region" maxlength="20"> </el-input>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="addClassTips()">取 消</el-button>
            <el-button type="primary" @click="addClassTips(1)">确 定</el-button>
        </span>
        </el-dialog>
        <!-- 添加班级 ------------------------------------------------ 弹窗 -->

        <!-- 编辑班级 ------------------------------------------------ 弹窗 -->
        <el-dialog
        title="编辑班级"
        :visible.sync="editTissueFlag"
        :close-on-click-modal="false" 
        :close-on-press-escape="false"
        @close="handleClose"
        width="40%"
        >
        <el-form ref="addTownForm" :model="addTownForm" label-width="120px" @submit.native.prevent>
            <el-form-item label="班级名称：" prop="region" :rules="[{message: '请输入班级名称',validator: checkValue}]">
            <el-input type="text" placeholder="" v-model.trim="addTownForm.region" maxlength="20"> </el-input>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="editTissueTips()">取 消</el-button>
            <el-button type="primary" @click="editTissueTips(1)">确 定</el-button>
        </span>
        </el-dialog>
        <!-- 编辑班级 ------------------------------------------------ 弹窗 -->

    </div>
</template>
<script>
    export default {
    data() {
        return {
            loading: {
                status: false,
                txt: "获取数据..."
            },
            defaultProps: {
                label: 'name',
            },
            orgData: [], //组织架构数据
            addEducationFlag: false,/*记录添加教育局弹窗状态 */
            editEducationFlag: false,/**记录编辑教育局弹窗状态 */
            educationForm: {
                eduname: '',/*记录添加教育局名称 */
                number: '',/*记录管理员账号 */
                password: '',/*记录管理员密码 */
            },
            addSchoolFlag: false,/*记录添加学校弹窗状态 */
            editSchoolFlag: false,/*记录编辑学校弹窗状态 */
            schoolForm: {
                schname: '',/*记录添加学校名称 */
                number: '',/*记录管理员账号 */
                password: '',/*记录管理员密码 */
                radio: 1, /**记录类型，1为普通教育，2为高等教育，3为成人教育 */
            },
            delEducationFlag: false, /*记录删除教育局弹窗状态 */
            delTissueFlag: false, /**记录删除组织弹窗状态 */
            stopEducationFlag: false, /*记录禁用教育局弹窗状态 */
            stopTissueFlag: false, /**记录禁用组织弹窗状态 */
            startEducationFlag: false, /*记录启用教育局弹窗状态 */
            startTissueFlag: false, /**记录启用组织弹窗状态*/
            delEducationForm: {
                password: '',/*验证超级管理员密码 */
            },
            delstop: { /**记录 删除/禁用 教育局/学校的id与 编码、名称 状态*/
                id: '',
                code: '', /**教育局的编码 */
                name: '',
                status: '', /**教育局/学校状态 */
            },
            addject: { /**记录添加教育局的id与 特殊字段 1为学校 2为教育局 */
                id: '',
                server_type: ''
            },
            addTownFlag: false, /**记录添加学段弹窗状态 */
            addFacultyFlag: false, /**记录添加院系弹窗状态 */
            addKindFlag: false, /**记录添加类别弹窗状态 */
            addGradeFlag: false, /** 记录添加年级弹窗状态 */
            addMajorFlag: false, /** 记录添加专业弹窗状态 */
            addClassFlag: false, /** 记录添加班级弹窗状态 */
            editTissueFlag: false, /**记录编辑班级弹窗状态 */
            editFieldFlag: false,/**记录编辑学段弹窗状态 */
            editFacFlag: false,/**记录编辑院系弹窗状态  */
            editKindFlag: false,/**记录编辑类别弹窗状态 */
            editClassFlag: false,/** 记录编辑年级弹窗状态*/
            editMajorFlag: false,/** 记录编辑专业弹窗状态*/
            addTownForm: {  /**添加组织 -------学段、学院、类别 */
                radio: 1, /**记录类型，1为普通教育，2为高等教育，3为成人教育 */
                region: '',
            },
            addxd: {  /**记录添加学段 要用到的参数 */
                id: '',  // 父级id （若添加学段时 则为1 其他都是获取父级id）
                level: '', // 级别（2：学段；3：年级；4：班级）
                status: '', // 状态
                app_code: '' // 父级学校编码
            },
            schoolChild: [],
            rules: { // 正则校验
                eduname: [ // 教育局
                    {required: true, validator: this.checkValue, message: '请填写教育局名称'},
                    {pattern: this.rules.chinese.reg, message: this.rules.chinese.msg,trigger: 'blur'}
                ],
                number: [ // 用户账号
                    {required: true, validator: this.checkValue, message: '账号由4-16位英文、数字、下划线组成', },
                    {pattern: this.rules.account.reg, message: this.rules.account.msg,trigger: 'blur'}
                ],
                password: [ // 用户密码
                    { validator: this.checkValue, message: '密码由6-16位英文、数字、下划线组成' },
                    {pattern: this.rules.pwd.reg, message: this.rules.pwd.msg,trigger: 'blur'}
                ],
                schname: [ // 学校
                    {required: true, validator: this.checkValue, message: '请输入学校名称'},
                    {pattern: this.rules.chinese.reg,message: this.rules.chinese.msg,trigger: 'blur'}
                ],
            },
            adminname: '',
        };
    },
    created() {
        this.getOrgData();
    },
    methods: {
        // getInformation(id) {
        //     let success = res =>{
        //         this.adminname = res.data.admin_number
        //     }
        //     this.$ajax.get('api/newlevel/platform', {params: {id: id}, func: {success}})
        // },
// 获取组织架构----------------------------------------------------------------------
        getOrgData() {
        this.loading.status = true;
        // 重写成功回调
        let success = res => {
            console.log(JSON.parse(JSON.stringify(res.data)))
            this.loading.status = false;
            this.orgData = res.data;
            if(this.orgData.length > 0 ){
            this.orgData[0].inx = 1;
            }
        
            this.$forceUpdate(); //强制渲染
        };

        let fail = data => {
            this.loading.status = false;
            this.$message.error(data.msg);
        };
        this.$ajax.get("api/newlevel/levelorg_list", {
            params: {},
            func: { success: success, fail: fail }
        });
        },
// 获取组织架构----------------------------------------------------------------------

// 添加教育局---------------------------------------------------------
        addEducationTrigger(data) {/*触发添加教育局弹窗 */
            console.log(data)
            this.addEducationFlag = true;
            if (this.$refs.educationForm) {
                this.$refs.educationForm.clearValidate();
            }
            this.addject = {
                id: data.id,
                server_type: 2,
            }
        },
        addEducationTips(flag) {/*控制添加教育局的弹窗 */
            if(this.educationForm.password == '') {
                this.educationForm.password = '666666'
            }
            if(flag) {
                /*确定的逻辑 */
                this.$refs[`educationForm`].validate(valid => {
                    if (valid) {
                        this.addEducation(this.addject);
                    } else {
                        return;
                    }
                })
            } else {
                this.addEducationWinHide();
            }
        },
        addEducation(addject) { /*添加教育局 */
            let params = {
                server_type: addject.server_type,
                pid: addject.id,
                name: this.educationForm.eduname,
                admin_number: this.educationForm.number,
                admin_password: this.educationForm.password,
            }
            const success=res=>{
                this.$message.success(res.msg);
                this.addEducationWinHide()
                this.getOrgData();
            }
            const fail = res => {
                this.$message.error(res.msg);
            }
            this.$ajax.post('api/newlevel/platform',params,{func:{success:success, fail: fail}})
        },
        addEducationWinHide() { // 清除输入框内容，关闭弹窗
            this.educationForm.eduname = '';
            this.educationForm.number = '';
            this.educationForm.password = '';
             this.$refs.educationForm.clearValidate();
            this.addEducationFlag = false;
        },
// 添加教育局---------------------------------------------------------

// 编辑教育局----------------------------------------------------------------------
        editEducationTrigger(data) {
            this.editEducationFlag = true
            if (this.$refs.educationForm) {
                this.$refs.educationForm.resetFields();
            }
            this.addject = {
                id: data.id
            }
            this.findEducation(data.id,data.app_code)
        },
        findEducation(id, app_code) {
            const success = res => {
                this.educationForm.eduname = res.data.name
                this.educationForm.number = res.data.admin_number
            }
            this.$ajax.get('api/newlevel/platform',{params: {id: id,app_code: app_code},func:{success}})
        },
        editEducationTips(flag) {
            if(flag) {
                if(this.educationForm.password == '') {
                    console.log(this.$refs[`educationForm`])
                    // 部分验证
                    this.$refs[`educationForm`].validateField('eduname', valid1 =>{
                        this.$refs[`educationForm`].validateField('number', valid2 =>{
                            if(!valid1 && !valid2){
                                this.editEducation(this.addject);
                            }
                        })
                    })
                }else {
                    /*确定的逻辑 */
                    this.$refs[`educationForm`].validate(valid => {
                    if (valid) {
                        this.editEducation(this.addject);
                    } else {
                        return;
                    }
                    })
                }
            } else {
                this.editEducationWinHide();
            }
        },
        editEducation(addject) {
             let params
            if( this.educationForm.password){
                params = {
                    id: addject.id,
                    name: this.educationForm.eduname,
                    admin_number: this.educationForm.number,
                    admin_password: this.educationForm.password
             }
            }else{
                params = {
                    id: addject.id,
                    name: this.educationForm.eduname,
                    admin_number: this.educationForm.number,
             }
            }
            
            let success = res => {
                this.$message.success(res.msg);
                this.editEducationWinHide();
                this.getOrgData();
            }
            const fail = res => {
                this.$message.error(res.msg);
            }
            this.$ajax.put('api/newlevel/platform',params,{func:{success:success, fail:fail}})
        },
        editEducationWinHide() { // 清除输入框内容，关闭弹窗
            this.educationForm.eduname = '';
            this.educationForm.number = '';
            this.educationForm.password = '';
            this.editEducationFlag = false;
            this.$refs.educationForm.resetFields();
        },
// 编辑教育局----------------------------------------------------------------------

// 编辑学校----------------------------------------------------------------------
        editSchoolTrigger(data) { //弹窗
            this.editSchoolFlag = true
            if (this.$refs.schoolForm) {
                this.$refs.schoolForm.resetFields();
            }
            this.addject = {
                id: data.id
            }
            this.findSchool(data.id,data.app_code)
            this.findSchoolChilden(data.id)
        },
        findSchool(id, app_code) {  // 获取学校信息
            const success = res => {
                this.schoolForm.schname = res.data.name
                this.schoolForm.number = res.data.admin_number
                this.schoolForm.radio = res.data.cate_type
            }
            this.$ajax.get('api/newlevel/platform',{params: {id: id,app_code: app_code},func:{success}})
        },
        findSchoolChilden(id){
            let params = {
                platform_id: id
            }
            const success = res => {
                this.schoolChild = res.data
            }
            this.$ajax.get('api/newlevel/platform_org',{params,func:{success}})
        },
        editSchoolTips(flag) {  // 控制弹窗
            if(flag) {
                if(this.schoolForm.password == '') {
                    this.$refs[`schoolForm`].validateField('schname', valid1 =>{
                        this.$refs[`schoolForm`].validateField('number', valid2 =>{
                            if(!valid1 && !valid2) {
                                this.editSchool(this.addject);
                            }
                        })
                    })
                }else {
                    /*确定的逻辑 */
                    this.$refs[`schoolForm`].validate(valid => {
                    if (valid) {
                        this.editSchool(this.addject);
                    } else {
                        return;
                    }
                    })
                }
            } else {
                this.editSchoolWinHide();
            }
        },
        editSchool(addject) {  // 编辑的方法  密码不传时默认不修改
             let params
            if( this.schoolForm.password){
              params = {
                id: addject.id,
                cate_type: this.schoolForm.radio,
                name: this.schoolForm.schname,
                admin_number: this.schoolForm.number,
                admin_password: this.schoolForm.password
             }
            }else{
                 params = {
                id: addject.id,
                cate_type: this.schoolForm.radio,
                name: this.schoolForm.schname,
                admin_number: this.schoolForm.number,
             }
            }
            
            let success = res => {
                this.$message.success(res.msg);
                this.editSchoolWinHide()
                this.getOrgData();
            }
            const fail = res => {
                this.$message.error(res.msg);
            }
            this.$ajax.put('api/newlevel/platform',params,{func:{success:success, fail:fail}})
        },
        editSchoolWinHide() {  // 清空输入框
            this.schoolForm.schname = '';
            this.schoolForm.number = '';
            this.schoolForm.password = '';
            this.editSchoolFlag = false;
            this.$refs['schoolForm'].clearValidate();
        },
// 编辑学校----------------------------------------------------------------------

// 编辑学段--------------------------------------------------------------------------
        editFieldTrigger(data) { //弹窗 方法与编辑班级共用
            this.delstop = {
                id: data.id,
                pid: data.pid,
                name: data.name,
                level: data.level,
                status: data.status
            }
            this.findTissue(data.id, data.level, data.name, data.app_code)
            this.editFieldFlag = true
            if (this.$refs.addTownForm) {
                this.$refs.addTownForm.resetFields();
            }
        },
// 编辑学段--------------------------------------------------------------------------

// 编辑院系---------------------------------------------
        editFacTrigger(data) {  //弹窗 方法与编辑班级共用
            this.delstop = {
                id: data.id,
                pid: data.pid,
                name: data.name,
                level: data.level,
                status: data.status
            }
            this.findTissue(data.id, data.level, data.name, data.app_code)
            this.editFacFlag = true
            if (this.$refs.addTownForm) {
                this.$refs.addTownForm.resetFields();
            }
        },
// 编辑院系---------------------------------------------

// 编辑类别-------------------------------------------------------
        editKindTrigger(data) {  //弹窗 方法与编辑班级共用
            this.delstop = {
                id: data.id,
                pid: data.pid,
                name: data.name,
                level: data.level,
                status: data.status
            }
            this.findTissue(data.id, data.level, data.name, data.app_code)
            this.editKindFlag = true
            if (this.$refs.addTownForm) {
                this.$refs.addTownForm.resetFields();
            }
        },
// 编辑类别-------------------------------------------------------

// 编辑年级-----------------------------------------------
        editClassTrigger(data) {  //弹窗 方法与编辑班级共用
            this.delstop = {
                id: data.id,
                pid: data.pid,
                name: data.name,
                level: data.level,
                status: data.status
            }
            this.findTissue(data.id, data.level, data.name, data.app_code)
            this.editClassFlag = true
            if (this.$refs.addTownForm) {
                this.$refs.addTownForm.resetFields();
            }
        },
// 编辑年级-----------------------------------------------

// 编辑专业---------------------------------------------------------
        editMajorTrigger(data) { //控制编辑专业弹窗
            this.delstop = {
                id: data.id,
                pid: data.pid,
                name: data.name,
                level: data.level,
                status: data.status
            }
            this.findTissue(data.id, data.level, data.name, data.app_code)
            this.editMajorFlag = true
            if (this.$refs.addTownForm) {
                this.$refs.addTownForm.resetFields();
            }
        },
// 编辑专业---------------------------------------------------------

// 编辑班级--------------------------------------------------------------------------
        editTissueTrigger(data) {  // 弹窗
            this.delstop = {
                id: data.id,
                pid: data.pid,
                name: data.name,
                level: data.level,
                status: data.status
            }
            this.findTissue(data.id, data.level, data.name, data.app_code)  // 传参调用组织架构
            this.editTissueFlag = true
            if (this.$refs.addTownForm) {
                this.$refs.addTownForm.resetFields();
            }
        },
        findTissue(id, level, name, app_code) {  // 获取组织架构
            const success = res => {
                this.addTownForm.region = res.data[0].name
            }
            this.$ajax.get('api/newlevel/platform_org',{params: {id: id, level: level, name: name,app_code: app_code},func:{success}})
        },
        editTissueTips(flag) {  // 控制弹窗
            if(flag) {
                /*确定的逻辑 */
                this.$refs[`addTownForm`].validate(valid => {
                if (valid) {
                    this.editTissue(this.delstop);
                } else {
                    return;
                }
                })
            } else {
                this.editTissueWinHide();
            }
        },
        editTissue(delstop) {  // 修改的参数上传
            let params = {
                id: delstop.id,
                pid: delstop.pid,
                name: this.addTownForm.region,
                level: delstop.level,
                status: delstop.status
            }
            let success = res => {
                this.$message.success(res.msg);
                this.editTissueWinHide()
                this.getOrgData();
            }
            const fail = res => {
                this.$message.error(res.msg);
            }
            this.$ajax.put('api/newlevel/platform_org',params,{func:{success:success, fail:fail}})
        },
        editTissueWinHide() {  // 退出关闭弹窗
            this.addTownForm.region = '';
            this.editTissueFlag = false;
            this.editFieldFlag = false;
            this.editFacFlag = false;
            this.editKindFlag = false;
            this.editClassFlag = false;
            this.editMajorFlag = false
        },
// 编辑班级--------------------------------------------------------------------------

// 删除教育局/学校---------------------------------------------------
        delEducationTrigger(id, app_code, name) {   // 删除教育局/学校弹窗
            this.delstop = {
                id: id,
                code: app_code,
                name: name
            }
            this.delEducationFlag = true;
            if (this.$refs.delEducationForm) {
                this.$refs.delEducationForm.resetFields();
            }
        },
        delEducationTips(flag) {/*控制删除教育局的弹窗 */

            let success = res => {
                if(flag) {
                    /*确定的逻辑 */
                    this.$refs[`delEducationForm`].validate(valid => {
                        if (valid) {
                            this.delEducation(this.delstop);
                        }
                    })
                } else {
                    this.delEducationwinHide();
                }
            }
            let fail = res => {
                if(!flag) {
                    this.delEducationwinHide();
                } else if(res.status == 'fail') {
                    return this.$message.error('密码错误')
                }
            }
            this.$ajax.get('api/user/check_user_by_id', {params: {
                id: this.$g.user_id,
                password: this.delEducationForm.password
            },func:{success, fail}})
        },
        delEducation(delstop) {/*删除教育局/学校 */
        let params = {
            id: delstop.id,
            app_code: delstop.code
        }
        const success=res=>{
            this.$message.success(res.msg);
            this.delEducationwinHide();
            this.getOrgData();
        }
        this.$ajax.delete('api/newlevel/platform',{params,func:{success:success}})
        },
        delEducationwinHide() {
            this.delEducationForm.password = ''
            this.delEducationFlag = false;
        },
// 删除教育局/学校---------------------------------------------------

// 禁用教育局/学校---------------------------------------------------------
        stopEducationTrigger(data) {/*触发禁用教育局弹窗 */
            this.delstop = {
                id: data.id,
                status: data.status,
                name: data.name
            }
            this.stopEducationFlag = true;
            if (this.$refs.delEducationForm) {
                this.$refs.delEducationForm.resetFields();
            }
        },
        stopEducationTips(flag) {
            let success = res => {
                if(flag) {
                    /*确定的逻辑 */
                    this.$refs[`delEducationForm`].validate(valid => {
                        if (valid) {
                            this.stopEducation(this.delstop);
                        }
                    })
                } else {
                    this.stopEducationWinHide()
                }
            }
            let fail = res => {
                if(!flag) {
                    this.stopEducationWinHide()
                } else if(res.status == 'fail') {
                    return this.$message.error('密码错误')
                }
            }
            this.$ajax.get('api/user/check_user_by_id', {params: {
                id: this.$g.user_id,
                password: this.delEducationForm.password
            },func:{success, fail}})
        },
        stopEducation(delstop) {
            let params = {
            id: delstop.id,
            status: delstop.status + 1,
            }
            const success=res=>{
                this.$message.success(res.msg);
                this.stopEducationWinHide()
                this.getOrgData();
            }
            const fail = res =>{
                this.$message.error(res.msg);
            }
            this.$ajax.put('api/newlevel/platform',params,{func:{success:success, fail:fail}})
        },
        stopEducationWinHide() {
            this.delEducationForm.password = ''
            this.stopEducationFlag = false;
            this.startEducationFlag = false;
        },
// 禁用教育局/学校---------------------------------------------------------

// 启用教育局/学校---------------------------------------------------------
        startEducationTrigger(data) {/*触发启用教育局弹窗 */
            this.delstop = {
                id: data.id,
                status: data.status,
                name: data.name
            }
            this.startEducationFlag = true;
            if (this.$refs.delEducationForm) {
                this.$refs.delEducationForm.resetFields();
            }
        },
        startEducationTips(flag) {
            let success = res => {
                if(flag) {
                    /*确定的逻辑 */
                    this.$refs[`delEducationForm`].validate(valid => {
                        if (valid) {
                            this.startEducation(this.delstop);
                        }
                    })
                } else {
                    this.stopEducationWinHide()
                }
            }
            let fail = res => {
                if(!flag) {
                    this.stopEducationWinHide()
                } else if(res.status == 'fail') {
                    return this.$message.error('密码错误')
                }
            }
            this.$ajax.get('api/user/check_user_by_id', {params: {
                id: this.$g.user_id,
                password: this.delEducationForm.password
            },func:{success, fail}})
        },
        startEducation(delstop) {
            let params = {
            id: delstop.id,
            status: delstop.status - 1,
            }
            const success=res=>{
                this.$message.success(res.msg);
                this.stopEducationWinHide()
                this.getOrgData();
            }
            this.$ajax.put('api/newlevel/platform',params,{func:{success:success}})
        },
// 启用教育局/学校---------------------------------------------------------

// 删除组织----------------------------------------------------------------------
        delTissueTrigger(data) {   // 删除组织弹窗

            this.delstop = {
                id: data.id,
                name: data.name
            }
            this.delTissueFlag = true;
            if (this.$refs.delEducationForm) {
                this.$refs.delEducationForm.resetFields();
            }

        },
        delTissueTips(flag) {/*控制删除组织的弹窗 */

            let success = res => {
                if(flag) {
                    /*确定的逻辑 */
                    this.$refs[`delEducationForm`].validate(valid => {
                        if (valid) {
                            this.delTissue(this.delstop);
                            this.delTissueWinHide()
                        }
                    })
                } else {
                    this.delTissueWinHide()
                }
            }
            let fail = res => {
                if(!flag) {
                    this.delTissueWinHide()
                } else if(res.status == 'fail') {
                    return this.$message.error('密码错误')
                }
            }
            this.$ajax.get('api/user/check_user_by_id', {params: {
                id: this.$g.user_id,
                password: this.delEducationForm.password
            },func:{success, fail}})
        },
        delTissue(delstop) { /*删除组织 */
            let params = {
                id: delstop.id,
            }
            const success=res=>{
                this.$message.success(res.msg);
                this.getOrgData();
            }
            this.$ajax.delete('api/newlevel/platform_org',{params,func:{success:success}})
        },
        delTissueWinHide() {
            this.delEducationForm.password = ''
            this.delTissueFlag = false;
        },
// 删除组织----------------------------------------------------------------------

// j禁用组织--------------------------------------------------------------------
        stopTissueTrigger(data) {/*触发禁用组织弹窗 */
            console.log(data)
            this.delstop = {
                id: data.id,
                status: data.status,
                name: data.name,
                level: data.level,
                pid: data.pid
            }
            this.stopTissueFlag = true;
            if (this.$refs.delEducationForm) {
                this.$refs.delEducationForm.resetFields();
            }
        },
        stopTissueTips(flag) {
            let success = res => {
                if(flag) {
                    /*确定的逻辑 */
                    this.$refs[`delEducationForm`].validate(valid => {
                        if (valid) {
                            this.stopTissue(this.delstop);
                            this.stopTissueWinHide()
                        }
                    })
                } else {
                    this.stopTissueWinHide()
                }
            }
            let fail = res => {
                if(!flag) {
                    this.stopTissueWinHide()
                } else if(res.status == 'fail') {
                    return this.$message.error('密码错误')
                }
            }
            this.$ajax.get('api/user/check_user_by_id', {params: {
                id: this.$g.user_id,
                password: this.delEducationForm.password
            },func:{success, fail}})
        },
        stopTissue(delstop) {
            let params = {
                id: delstop.id,
                name: delstop.name,
                status: delstop.status + 1,
                level: delstop.level,
                pid: delstop.pid
            }
            const success=res=>{
                this.$message.success(res.msg);
                this.getOrgData();
            }
            const fail = res =>{
                this.$message.error(res.msg);
            }
            this.$ajax.put('api/newlevel/platform_org',params,{func:{success:success, fail:fail}})
        },
        stopTissueWinHide() {
            this.delEducationForm.password = ''
            this.stopTissueFlag = false;
        },
// j禁用组织--------------------------------------------------------------------

// 启用组织---------------------------------------------------------------------------
        startTissueTrigger(data) {
            console.log(data)
            this.delstop = {
                id: data.id,
                status: data.status,
                name: data.name,
                level: data.level,
                pid: data.pid
            }
            this.startTissueFlag = true;
            if (this.$refs.delEducationForm) {
                this.$refs.delEducationForm.resetFields();
            }
        },
        startTissueTips(flag) {
            let success = res => {
                if(flag) {
                    /*确定的逻辑 */
                    this.$refs[`delEducationForm`].validate(valid => {
                        if (valid) {
                            this.startTissue(this.delstop);
                            this.startTissueWinHide()
                        }
                    })
                } else {
                    this.startTissueWinHide()
                }
            }
            let fail = res => {
                if(!flag) {
                    this.startTissueWinHide()
                } else if(res.status == 'fail') {
                    return this.$message.error('密码错误')
                }
            }
            this.$ajax.get('api/user/check_user_by_id', {params: {
                id: this.$g.user_id,
                password: this.delEducationForm.password
            },func:{success, fail}})
        },
        startTissue(delstop) {
            let params = {
            id: delstop.id,
            name: delstop.name,
            status: delstop.status - 1,
            level: delstop.level,
            pid: delstop.pid
            }
            const success=res=>{
                this.$message.success(res.msg);
                this.getOrgData();
            }
            const fail = res =>{
                this.$message.error(res.msg);
            }
            this.$ajax.put('api/newlevel/platform_org',params,{func:{success:success, fail:fail}})
        },
        startTissueWinHide() {
            this.delEducationForm.password = ''
            this.startTissueFlag = false;
        },
// 启用组织---------------------------------------------------------------------------

        checkValue(rule, value, callback) {
            if (!checkSpace(value)) {
                callback(new Error("请输入有效值"));
            }else {
                callback();
            }
        },

// 添加学校----------------------------------------------------------------------------------------------------------
        addSchoolTrigger(id) {/*触发添加学校弹窗 */
            this.addject = {
                id: id,
                server_type: 1,
            }
            this.addSchoolFlag = true;
            if (this.$refs.schoolForm) {
                this.$refs.schoolForm.resetFields();
            }
        },
        addSchool(addject) {/*添加学校 */
            let params = {
                server_type: addject.server_type,
                pid: addject.id,
                name: this.schoolForm.schname,
                cate_type: this.schoolForm.radio,
                admin_number: this.schoolForm.number,
                admin_password: this.schoolForm.password,
            }
            const success=res=>{
                this.$message.success(res.msg);
                this.addSchoolWinHide();
                this.getOrgData();
            }
            const fail = res => {
                this.$message.error(res.msg);
            }
            
            this.$ajax.post('api/newlevel/platform',params,{func:{success:success, fail: fail}})
        },
        addSchoolWinHide() { // 清除输入框内容，关闭弹窗
            this.schoolForm.schname = '';
            this.schoolForm.radio = 1;
            this.schoolForm.number = '';
            this.schoolForm.password = '';
            this.addSchoolFlag = false;
            this.$refs.schoolForm.resetFields();
        },
        addSchoolTips(flag) {/*控制添加学校的弹窗 */
           this.schoolForm.password =  this.schoolForm.password == '' ? '666666' : this.schoolForm.password
            if(flag) {
                /*确定的逻辑 */
                this.$refs[`schoolForm`].validate(valid => {
                if (valid) {
                    this.addSchool(this.addject);
                } else {
                    return;
                }
                })
            } else {
                this.addSchoolWinHide();
            }
        },
// 添加学校----------------------------------------------------------------------------------------------------------

// 添加学段------------------------------------------------------------------------
        addTownFlagTrigger(data) {  /**触发弹窗 */
            this.addxd = {
                id: 1,
                status: data.status,
                level: 2,
                app_code: data.app_code
            }
            this.addTownFlag = true
        },
        addTownTips(flag) {
            if(flag) {
                /*确定的逻辑 */
                this.$refs[`addTownForm`].validate(valid => {
                if (valid) {
                    this.addTown(this.addxd);
                } else {
                    return;
                }
                })
            } else {
                this.addTownWinHide();
            }
        },
        addTown(addxd) {
            let params = {
                name: this.addTownForm.region,
                pid: addxd.id,
                level: addxd.level,
                status: addxd.status,
                app_code: addxd.app_code
            }
            const success=res=>{
                this.$message.success(res.msg);
                this.addTownWinHide();
                this.getOrgData();
            }
            const fail = res => {
                this.$message.error(res.msg);
            }
            this.$ajax.post('api/newlevel/platform_org',params,{func:{success:success, fail: fail}})
        },
        addTownWinHide() { // 清除输入框内容，关闭弹窗
            this.addTownForm.region = '';
            this.addTownFlag = false;
        },
// 添加学段------------------------------------------------------------------------

// 添加院系 faculty------------------------------------------------------------------
        addFacultyFlagTrigger(data) {  /**触发弹窗 */
            this.addxd = {
                id: 1,
                status: data.status,
                level: 2,
                app_code: data.app_code
            }
            this.addFacultyFlag = true
            if (this.$refs.addTownForm) {
                this.$refs.addTownForm.resetFields();
            }
        },
        addFacultyTips(flag) {
            if(flag) {
                /*确定的逻辑 */
                this.$refs[`addTownForm`].validate(valid => {
                    if (valid) {
                        this.addFaculty(this.addxd);
                    } else {
                        return;
                    }
                })
            } else {
                this.addFacultyWinHide();
            }
        },
        addFaculty(addxd) {
            let params = {
                name: this.addTownForm.region,
                pid: addxd.id,
                level: addxd.level,
                status: addxd.status,
                app_code: addxd.app_code
            }
            const success=res=>{
                this.$message.success(res.msg);
                this.addFacultyWinHide();
                this.getOrgData();
            }
            const fail = res => {
                this.$message.error(res.msg);
            }
            this.$ajax.post('api/newlevel/platform_org',params,{func:{success:success, fail: fail}})
        },
        addFacultyWinHide() { // 清除输入框内容，关闭弹窗
            this.addTownForm.region = '';
            this.addFacultyFlag = false;
            this.$refs.addTownForm.resetFields();
        },
// 添加院系 faculty------------------------------------------------------------------

// 添加类别 kind------------------------------------------------------------------
        addKindFlagTrigger(data) {  /**触发弹窗 */
            this.addxd = {
                id: 1,
                status: data.status,
                level: 2,
                app_code: data.app_code
            }
            this.addKindFlag = true
            if (this.$refs.addTownForm) {
                this.$refs.addTownForm.resetFields();
            }
        },
        addKindTips(flag) {
            if(flag) {
                /*确定的逻辑 */
                this.$refs[`addTownForm`].validate(valid => {
                if (valid) {
                    this.addKind(this.addxd);
                } else {
                    return;
                }
                })
            } else {
                this.addKindWinHide();
            }
        },
        addKind(addxd) {
            let params = {
                name: this.addTownForm.region,
                pid: addxd.id,
                level: addxd.level,
                status: addxd.status,
                app_code: addxd.app_code
            }
            const success=res=>{
                this.$message.success(res.msg);
                this.addKindWinHide();
                this.getOrgData();
            }
            const fail = res => {
                this.$message.error(res.msg);
            }
            this.$ajax.post('api/newlevel/platform_org',params,{func:{success:success, fail: fail}})
        },
        addKindWinHide() { // 清除输入框内容，关闭弹窗
            this.addTownForm.region = '';
            this.addKindFlag = false;
        },
// 添加类别 kind------------------------------------------------------------------

// 添加年级 ------------------------------------------------------------------
        addGradeFlagTrigger(data) {
            this.addxd = {
                id: data.id,
                status: data.status,
                level: 3,
                app_code: data.app_code
            }
            this.addGradeFlag = true
            if (this.$refs.addTownForm) {
                this.$refs.addTownForm.resetFields();
            }
        },
        addGradeTips(flag) {
            if(flag) {
                /*确定的逻辑 */
                this.$refs[`addTownForm`].validate(valid => {
                if (valid) {
                    this.addGrade(this.addxd);
                } else {
                    return;
                }
                })
            } else {
                this.addGradeWinHide();
            }
        },
        addGrade(addxd) {
            let params = {
                name: this.addTownForm.region,
                pid: addxd.id,
                level: addxd.level,
                status: addxd.status,
                app_code: addxd.app_code
            }
            const success=res=>{
                this.$message.success(res.msg);
                this.addGradeWinHide();
                this.getOrgData();
            }
            const fail = res => {
                this.$message.error(res.msg);
            }
            this.$ajax.post('api/newlevel/platform_org',params,{func:{success:success, fail: fail}})
        },
        addGradeWinHide() { // 清除输入框内容，关闭弹窗
            this.addTownForm.region = '';
            this.addGradeFlag = false;
        },
// 添加年级 ----------------------------------------------------------------------------------------

// 添加专业 -----------------------------------------------------------------------------------------------
        addMajorFlagTrigger(data) {
            this.addxd = {
                id: data.id,
                status: data.status,
                level: 3,
                app_code: data.app_code
            }
            this.addMajorFlag = true
            if (this.$refs.addTownForm) {
                this.$refs.addTownForm.resetFields();
            }
        },
        addMajorTips(flag) {
            if(flag) {
                /*确定的逻辑 */
                this.$refs[`addTownForm`].validate(valid => {
                if (valid) {
                    this.addMajor(this.addxd);
                } else {
                    return;
                }
                })
            } else {
                this.addMajorWinHide();
            }
        },
        addMajor(addxd) {
            let params = {
                name: this.addTownForm.region,
                pid: addxd.id,
                level: addxd.level,
                status: addxd.status,
                app_code: addxd.app_code
            }
            const success=res=>{
                this.$message.success(res.msg);
                this.addMajorWinHide();
                this.getOrgData();
            }
            const fail = res => {
                this.$message.error(res.msg);
            }
            this.$ajax.post('api/newlevel/platform_org',params,{func:{success:success, fail: fail}})
        },
        addMajorWinHide() { // 清除输入框内容，关闭弹窗
            this.addTownForm.region = '';
            this.addMajorFlag = false;
        },
// 添加专业 -----------------------------------------------------------------------------------------------

// 添加班级 -----------------------------------------------------------------------------------------------------
        addClassFlagTrigger(data) {  // 添加班级弹窗
            this.addxd = {
                id: data.id, // 存父级id
                status: data.status, // 存父级状态
                level: 4,
                app_code: data.app_code // 存父级 学校码
            }
            this.addClassFlag = true
            if (this.$refs.addTownForm) {
                this.$refs.addTownForm.resetFields();
            }
        },
        addClassTips(flag) {  // 控制添加班级弹窗
            if(flag) {
                /*确定的逻辑 */
                this.$refs[`addTownForm`].validate(valid => {
                if (valid) {
                    this.addClass(this.addxd);
                } else {
                    return;
                }
                })
            } else {
                this.addClassWinHide();
            }
        },
        addClass(addxd) {  // 添加班级的方法
            let params = {
                name: this.addTownForm.region,
                pid: addxd.id,
                level: addxd.level,
                status: addxd.status,
                app_code: addxd.app_code
            }
            const success=res=>{
                this.$message.success(res.msg);
                this.addClassWinHide();
                this.getOrgData();
            }
            const fail = res => {
                this.$message.error(res.msg);
            }
            this.$ajax.post('api/newlevel/platform_org',params,{func:{success:success, fail: fail}})
        },
        addClassWinHide() {  // 清除输入框内容，关闭弹窗
            this.addTownForm.region = '';
            this.addClassFlag = false;
        },
// 添加班级 -----------------------------------------------------------------------------------------------------

        handleClose() { // 点击右上角 × 退出并清空输入框遗留内容
            this.educationForm.eduname = '';
            this.educationForm.number = '';
            this.educationForm.password = '';
            this.schoolForm.schname = '';
            this.schoolForm.number = '';
            this.schoolForm.password = '';
            this.schoolForm.radio = 1;
            this.addTownForm.region = '';
            this.delEducationForm.password = '';
        },
    }
};
</script>

<style lang="scss">
.zh-organization {
    .frame-manage {
    .el-tree {
        height: auto;
    }
    .frame-list {
        display: flex;
        height: 40px;
        line-height: 40px;
        background: #ddd;
        color: #000;
        text-align: center;
        li {
        flex: 1;
        box-sizing: border-box;
        &:nth-of-type(1) {
            flex: 0 0 60px;
        }
        &:nth-of-type(3) {
            flex: 0 0 160px;
            .link {
            color: #348EFC;
            cursor: pointer;
            }
        }
        &:nth-of-type(4) {
            flex: 0 0 160px;
        }
        }
    }
    .custom-tree-node {
        width: 100%;
        .frame-list {
        background: none;
        border-bottom: 1px solid #ddd;
        li {
            position: relative;
            border-left: 1px solid #ddd;
            &:last-child {
            border-right: 1px solid #ddd;
            }
        }
        img {
            display: inline-block;
            vertical-align: middle;
        }
        }
    }
    .el-tree-node__content {
        li:nth-of-type(2) .ellips {
        text-align: left;
        padding-left: 5%;
        .gap {
            display: inline-block;
            width: 18px;
        }
        }
    }
    }
}
</style>